package router

import (
	"portal_api/api"
	"portal_api/middleware"

	"github.com/gin-gonic/gin"
)

func InitApiRouter(r *gin.RouterGroup) {

	proveRouter := r.Group("/prove")
	{
		// proveRouter.POST("/create", middleware.JWTAuth(), middleware.IsPortalPorver(), api.PostCreatePortalProver)
		proveRouter.POST("/create", api.PostCreatePortalProver)
		proveRouter.POST("/device/create", middleware.IsPortalRegisterd(), api.PostCreatePortalProver)
		proveRouter.GET("", api.GetPortalRecord)
		proveRouter.GET("/hash/:hash", api.GetPortalRecordByHash)
	}

	deviceRouter := r.Group("/device")
	{
		deviceRouter.POST("/register", middleware.JWTAuth(), middleware.IsPortalPorver(), api.PostRegisterPortalDevice)
		deviceRouter.GET("/mac/:address", api.GetPortalDeviceByMacAddress)
		deviceRouter.GET("/code/:address", api.GetPortalDeviceByPortalCode)
	}
}
